package top.yuyufeng.learn.lucene.solr;

import org.apache.solr.client.solrj.impl.HttpSolrClient;

/**
 * @author yuyufeng
 * @date 2017/12/6
 */
public class SolrServer {
    private static HttpSolrClient server = null;
    private final static String solrServerUrl = "http://127.0.0.1:8983/solr/blog";

    public static HttpSolrClient getServer() {
        if (server == null) {
            server = new HttpSolrClient(solrServerUrl);
            server.setDefaultMaxConnectionsPerHost(1000);
            server.setMaxTotalConnections(10000);//最大连接数
            server.setConnectionTimeout(60000);//设置连接超时时间（单位毫秒） 1000
            server.setSoTimeout(60000);//// 设置读数据超时时间(单位毫秒) 1000
            server.setFollowRedirects(false);//遵循从定向
            server.setAllowCompression(true);//允许压缩
        }
        return server;
    }

    public static void main(String[] args) {
        HttpSolrClient client = getServer();
        System.out.println(client);
    }
}
